from PyQt5.QtWidgets import QMessageBox

'''
消息框工具类，提供警告 通知 询问三种方式
'''
def warning(title: str, text: str, buttons=QMessageBox.Ok):
    msgbox = QMessageBox()
    msgbox.setIcon(QMessageBox.Warning)  # 设置图标
    msgbox.setWindowTitle(title)  # 设置标题
    msgbox.setText(text)  # 设置内容
    msgbox.setStandardButtons(buttons)  # 设置提供按钮
    reply = msgbox.exec()  # 返回用户点击结果
    return reply


def information(title: str, text: str, buttons=QMessageBox.Ok):
    msgbox = QMessageBox()
    msgbox.setIcon(QMessageBox.Information)  # 设置图标
    msgbox.setWindowTitle(title)  # 设置标题
    msgbox.setText(text)  # 设置内容
    msgbox.setStandardButtons(buttons)  # 设置提供按钮
    reply = msgbox.exec()  # 返回用户点击结果
    return reply


def question(title: str, text: str, buttons):
    msgbox = QMessageBox()
    msgbox.setIcon(QMessageBox.Question)  # 设置图标
    msgbox.setWindowTitle(title)  # 设置标题
    msgbox.setText(text)  # 设置内容
    msgbox.setStandardButtons(buttons)  # 设置提供按钮
    reply = msgbox.exec()  # 返回用户点击结果
    return reply
